package yushuman.rbac.domain.entity;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 实体类-基类
 *
 * @author 俞舒熳
 * @since 2025/6/5 16:58
 */
public abstract class BaseEntity implements Serializable {

    /**
     * 主键 ID，只读的属性
     */
    private Integer id;
    /**
     * 创建时间
     */
    public LocalDateTime createAt;

    /**
     * 更新时间
     */
    public LocalDateTime updateAt;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public BaseEntity() {
    }

    public BaseEntity(Integer id, LocalDateTime createAt, LocalDateTime updateAt) {
        this.id = id;
        this.createAt = createAt;
        this.updateAt = updateAt;
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;
        BaseEntity that = (BaseEntity) o;
        return Objects.equals(id, that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }
}
